package ua.dogar.sockets;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import java.net.Socket;
import java.net.UnknownHostException;

import ua.dogar.test.Vectors;
import ua.dogar.vectors.Vector;

public class SocketTest {

	/**
	 * @param args
	 * @throws IOException
	 * @throws UnknownHostException
	 */
	public static void main(String[] args) throws UnknownHostException,
			IOException {
		Socket clientSocket = new Socket("localhost",7843);
		FileReader fr =new FileReader(new File(args[0]));
		Vector vec ;
		FileWriter fw = new FileWriter(new File(args[1]));
		while((vec = Vectors.readVector(fr))!=null){
		Vectors.outputVector(
				vec,
				clientSocket.getOutputStream());
		
		 Vectors.outputVector(
				Vectors.readVector(fr),
				clientSocket.getOutputStream());

		 Vectors.writeVector(Vectors.inputVector(clientSocket.getInputStream()),fw);
		}
		
		
		
		clientSocket.close();
		
	}

}
